﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StructureMap;
using OdsServer.Core;
using OdsServer.Common;

namespace OdsServer
{
    public static class OdsServerRepository
    {
        public static void Initialize()
        {
            IocHelper.SetupIoc();

#if DEBUG
            IocHelper.SetProfile(IocHelper.DebugProfile);
#else 
            IocHelper.SetProfile(IocHelper.ProductionProfile);
#endif

            ObjectFactory.AssertConfigurationIsValid();
        }

        public static void SetProcessingDeviceAI(IDeviceInteropAI deviceInteropAI)
        {
            ObjectFactory.AssertConfigurationIsValid();

            ObjectFactory.Configure(conf =>
                {
                    conf.Profile(ObjectFactory.Profile, pAction =>
                        {
                            pAction.For<IDeviceInteropAI>().Use(deviceInteropAI);
                        } );
                } );
        }

        public static IServerService GetServer()
        {
            return ObjectFactory.GetInstance<OdsServerService>();
        }
    }
}
